import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { JobPeopleVO, JobPeopleForm, JobPeopleQuery } from '@/api/general/jobPeople/types';

/**
 * 查询班组人员列表
 * @param query
 * @returns {*}
 */

export const listJobPeople = (query?: JobPeopleQuery): AxiosPromise<JobPeopleVO[]> => {
  return request({
    url: '/general/jobPeople/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询班组人员详细
 * @param userId
 */
export const getJobPeople = (userId: string | number): AxiosPromise<JobPeopleVO> => {
  return request({
    url: '/general/jobPeople/' + userId,
    method: 'get'
  });
};

/**
 * 新增班组人员
 * @param data
 */
export const addJobPeople = (data: JobPeopleForm) => {
  return request({
    url: '/general/jobPeople',
    method: 'post',
    data: data
  });
};

/**
 * 修改班组人员
 * @param data
 */
export const updateJobPeople = (data: JobPeopleForm) => {
  return request({
    url: '/general/jobPeople',
    method: 'put',
    data: data
  });
};

/**
 * 删除班组人员
 * @param userId
 */
export const delJobPeople = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/general/jobPeople/' + userId,
    method: 'delete'
  });
};
